package com.ruoyi.system.api;

import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.common.core.constant.ServiceNameConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.api.domain.File;
import com.ruoyi.system.api.domain.FileData;
import com.ruoyi.system.api.domain.FileObject;
import com.ruoyi.system.api.factory.RemoteFileDataFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 日志服务
 *
 * @author ruoyi
 */
@FeignClient(contextId = "remoteFileDataService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteFileDataFallbackFactory.class)
public interface RemoteFileDataService {
    @PostMapping("/file/fileData")
    public R<Boolean> saveFileDataList(@RequestBody FileObject fileObject, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/file/remote/data")
    public R<List<FileData>> selectFileDataList(@RequestParam("groupId") Long groupId, @RequestParam(value = "fileTypes") String fileTypes);

    @PostMapping("/file")
    public R<Boolean> saveFileList(@RequestParam("groupId") Long groupId, @RequestParam("typeId") Integer typeId, @RequestParam("fileIds") List<Long> fileIds, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/file")
    public R<List<File>> selectFileList(@RequestParam("groupId") Long groupId, @RequestParam(value = "typeIds") String typeIds, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/file")
    public R<List<File>> selectFileList(@SpringQueryMap File file, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @PostMapping(value = "/file/autoUpload/fileSave",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public R<File> autoUploadFileSave(@RequestPart("fileData") File fileData, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping(value = "/file/fileBytes/{fileId}")
    public R<byte[]> fileBytes(@PathVariable("fileId") Long fileId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping(value = "/file/fileBytesByGroup/{fileId}")
    public R<List<byte[]>> fileBytesByGroup(@PathVariable("fileId") Long fileId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @DeleteMapping(value = "/file/delete/contract/{fileId}")
    public R<Integer> removeFile(@PathVariable("fileId") Long fileId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @PutMapping("/file/splitFileList")
    public R<Integer> replaceFileList(@RequestBody File file, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @PostMapping(value = "/file/remote/saveFile")
    public R saveFile(@RequestBody File file,@RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @DeleteMapping(value = "/file/remote/deleleByProcInsId")
    public R<Integer> deleleByProcInsId(@RequestBody File file, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

}
